import 'package:json_annotation/json_annotation.dart';

part 'miffy_product_list_api.g.dart';

@JsonSerializable()
class MiffyProduct {
  final String? pid;
  final String? tuyaPid;
  final String? name;
  final String? model;

  MiffyProduct({this.pid, this.tuyaPid, this.name, this.model});

  /// 反序列化（JSON → Dart对象）
  factory MiffyProduct.fromJson(Map<String, dynamic> json) =>
      _$MiffyProductFromJson(json);

  /// 序列化（Dart对象 → JSON）
  Map<String, dynamic> toJson() => _$MiffyProductToJson(this);

  /// 可选：实现copyWith方法
  MiffyProduct copyWith({
    String? pid,
    String? tuyaPid,
    String? name,
    String? model,
  }) {
    return MiffyProduct(
      pid: pid ?? this.pid,
      tuyaPid: tuyaPid ?? this.tuyaPid,
      name: name ?? this.name,
      model: model ?? this.model,
    );
  }
}
